var page_fullscreen = {
    effect: null,
    fullscreen : null,
    caches : {},
    init: function() {

		//remove contactf-img1 height css
       // 处理图片轮换效果
      /*page_fullscreen.effect = $("#contacte-top").fadeTransition();
       $("#contacte-con-1 ul").each(function() {
            $(this).children().each(function(_idx) {
                  $(this).click(function() { 
                    page_fullscreen.effect.showItem(_idx);
                  })
            });
       }); */

	 // 处理全屏效果
	page_fullscreen.fullScreen = $('#fullscreenblock').fullScreen();
	
	$(page_fullscreen.fullScreen).bind('fullscreenShow', function() {
		$(window).bind('resize', {scope: this}, function(evt) {
			evt.data.scope.doLayout();
		})
		.bind('scroll',  {scope: this}, function(evt) {
			evt.data.scope.doLayout();
		});
		this.gallery.find('#btnExit').bind('click', {scope: this}, function(evt) {
			evt.data.scope.hide();
		});
		if (page_fullscreen.caches.loaded == undefined) {
			 this.gallery.width('100%')
					  .find('.rotator').css({'width': '100%', 'text-align': 'center'}).end()
					  .find('.contactf-img').css({'height': 'auto', 'width': '100%'}).end()
					  .find('.sareafull').css({'margin-bottom': '20px', 'width': '100%'}).end()
					  .find('.contactf-1').css({'text-align': 'center', 'height': '35px', 'width': '100%'}).end()
					  .find('.contactf-img1 img').css({'margin-top' : '0px'});
			
			var _computedWidth = 0;
			this.gallery.find('.navicontrollerfull li img').each(function() {
				_computedWidth += $(this).width() + 7;
			})
			var _computedHeight = this.gallery.find('.navicontrollerfull li img').eq(0).height();
			this.gallery.find('.navicontrollerfull').css({'width': _computedWidth, 'height': _computedHeight, 'margin': '0 auto'});

			var _img = {'width' : 1080, 'height' : 595};
			page_fullscreen.caches.imgScale = _img.width / _img.height;

			page_fullscreen.caches.heightPadding = page_fullscreen.fullScreen.container.outerHeight(true) - page_fullscreen.fullScreen.gallery.height();
			page_fullscreen.caches.loaded = 'true';
		}
       });
	$(page_fullscreen.fullScreen).bind('fullscreenShown', function() {
		if (page_fullscreen.caches.shown == undefined) {
			page_fullscreen.caches.shown = 'true';
		}
	});
	$(page_fullscreen.fullScreen).bind('fullscreenApplyLayout', function() {
		(function(_fullScreen) {
			_fullScreen.gallery.find('.sareafull img').each(function() {
				var _height = $(this).height();
				_height = _fullScreen.container.height() - page_fullscreen.caches.heightPadding - 140;
				if (_height <= 30) { _height = 30; }
				if (_height > 595) { _height = 595;}
				
				if ( _height * page_fullscreen.caches.imgScale + 10 >= _fullScreen.container.width() ) {
					_height = (_fullScreen.container.width() - 10) / page_fullscreen.caches.imgScale;
				}

				$(this).height(_height + 'px');
				_fullScreen.gallery.find('.sareafull').height(_height + 'px');
				//page_transition_full.locationbtn();
				/*var _offsetLeft  = $(this).offset().left;
				_fullScreen.gallery.find('.contactf-1').css({'margin-left': _offsetLeft});*/
			});
		})(this);
	});

      $('#btnFullScreen').click(function() {
	 page_fullscreen.fullScreen.show();
	 page_transition_full.locationbtn();
	 //page_transition_full.addctrbtn();
      });

      //page.effect = $(".contactf-img1").fadeTransition();
     // $('#fullscreenblock').css("top","10");
      //page_fullscreen.layout();
      /*$(window).resize(function() {
	if (page_fullscreen.fullScreen.visiable == true) {
		page_fullscreen.fullScreen.doLayout();
	}else{
		return false;
	}*/
      },
    
	/*layout:function(){
	
	  	page_fullscreen.fullScreen.gallery.find(".contactf-img img").each(function(){
  			if($(this).css('display') != 'none')
         	{
         		var screentWidth = $(window).width();
         		var imgWidth = screentWidth*0.8;
         		$(this).css('width',imgWidth+'px');
         		//$(".sareafull").css('width',imgWidth+'px');
         		page_fullscreen.fullScreen.doLayout();
         	}
  		});
  		
  			var screentWidth = $(window).width();
         		var imgWidth = screentWidth*0.8;
         		page_fullscreen.fullScreen.gallery.css('width',imgWidth+'px');
         		page_fullscreen.fullScreen.doLayout();
  		
	},*/
    show: function(idx) {
       page_fullscreen.effect.showItem(idx);
    }
};
/*
$(function(){
	page_fullscreen.init();
});*/

(function($){
    $.fn.extend({
        center: function () {
            return this.each(function() {
                var top = ($(window).height() - $(this).outerHeight()) / 2;
                var left = ($(window).width() - $(this).outerWidth()) / 2;
                $(this).css({position:'absolute', margin:0, top: (top > 0 ? top : 0)+'px', left: (left > 0 ? left : 0)+'px'});
            });
        }
    }); 
   $.fn.extend({
        left: function () {
            return this.each(function() {
                var top = ($(window).height() - $(this).outerHeight()) / 2;
                var left = 0;
                $(this).css({position:'absolute', margin:0, top: (top > 0 ? top : 0)+'px', left: (left > 0 ? left : 0)+'px'});
            });
        }
    });  
    $.fn.extend({
        right: function () {
            return this.each(function() {
                var top = ($(window).height() - $(this).outerHeight()) / 2;
                var left = $(window).width() - $(this).outerWidth();
                $(this).css({position:'absolute', margin:0, top: (top > 0 ? top : 0)+'px', left: (left > 0 ? left : 0)+'px'});
            });
        }
    }); 
    
    $.fn.extend({
        bottom: function () {
            return this.each(function() {
                var top = $(window).height() - $(this).outerHeight();
               // var left = $(window).width() - $(this).outerWidth();
                $(this).css({position:'absolute', margin:0, top: (top > 0 ? top : 0)+'px'});
            });
        }
    }); 
})(jQuery);
